import Cookies from 'js-cookie'

const TokenKey = 'token'


export function getToken () {
  return localStorage.getItem(TokenKey)
  // return Cookies.get(TokenKey)
}

export function setToken (token) {
  return localStorage.setItem(TokenKey, token)
  // return Cookies.set(TokenKey, token)
}

export function removeToken () {
  return localStorage.removeItem(TokenKey)
}


export function getUserInfo () {
	let info = localStorage.getItem('USER_INFO')
	let result = JSON.parse(info)
  return result;
}

export function setUserInfo (userinfo) {
	let info = JSON.stringify(userinfo);
  return localStorage.setItem('USER_INFO', info)
}


export function getAdminInfo () {
	let info = localStorage.getItem('ADMIN_INFO')
	let result = JSON.parse(info)
  return result;
}

export function setAdminInfo (userinfo) {
	let info = JSON.stringify(userinfo);
  return localStorage.setItem('ADMIN_INFO', info)
}


export function getStorageCache ($key) {
	let info = localStorage.getItem($key)
	let result = JSON.parse(info)
  return result;
}

export function setStorageCache($key,$list) {
	let info = JSON.stringify($list);
  return localStorage.setItem($key, info)
}



export function getTabInfo () {
	let info = localStorage.getItem('TAB_INFO')
	let result = JSON.parse(info)
  return result;
}

export function setTabInfo (userinfo) {
	let info = JSON.stringify(userinfo);
  return localStorage.setItem('TAB_INFO', info)
}

export function removeTabInfo () {
  return localStorage.removeItem('TAB_INFO')
}